import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from 'path';
import pxtorem from "postcss-pxtorem";

// https://vitejs.dev/config/
export default defineConfig({
	resolve: {
		alias: {
			'@': path.resolve(__dirname, 'src'),//用“@”代替路径
		},
	},
	plugins: [
		vue({
			template: {
				compilerOptions: {
					isCustomElement: tag => tag === "sapn"
				}
			}
		})
	],
	css: {
		postcss: {
			plugins: [
				pxtorem({
					// 设计稿宽度的1/10，通常是750的1/10
					rootValue: 192,
					propList: ["*", "!border"],
					// 要忽略的选择器
					selectorBlackList: ["van"],
					replace: true, // 直接更换成rem
					mediaQuery: false, // 是否要在媒体查询中转换px
					minPixelValue: 2 // 设置要转换的最小像素值
				})
			]
		},
		preprocessorOptions: {
			scss: {
				additionalData: '@import "./src/style/variable.scss";' // 引入全局变量文件
			}
		}
	}
});
